﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Data;
using ModuleDALCore;
using QUANLYCHAMCONG.DAO.Core;
using QUANLYCHAMCONG.BL.Entities.Security;

namespace QUANLYCHAMCONG.DAO.DAO.Security
{
   public class MENUGROUPDAO:DALBase
    {
       MENUGROUP mngr;
         private string _SpName;
         private string _SPAuthencation = "SpPhanQuyen";
        public string SpName
        {
            get { return "SpMENUGROUP"; }
            set { _SpName = value; }
        }
        public MENUGROUPDAO()
        {
            OpenConnect();
        }
        public bool Insert(MENUGROUP mngr)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr,1)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Update(MENUGROUP mngr)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr,2)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Delete(MENUGROUP mngr)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr,3)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool DeleteEdit(MENUGROUP mnu)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(mnu, null), ConvertClassToArray.GetValues(mnu, 5)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public DataTable SelectByPK(MENUGROUP mngr)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr,4));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALL()
        {
            mngr = new MENUGROUP();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr,0));
            }
            catch
            {
                return null;
            }
        }
        public int GetID()
        {
            mngr = new MENUGROUP();
            try
            {
                return DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(mngr, null), ConvertClassToArray.GetValues(mngr, 5), DBConnectionState.CloseOnExit);
            }
            catch
            {
                return 0;
            }
        }
        public DataTable SelectFlowForm(Authencation au)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(_SPAuthencation, ConvertClassToArray.GetParamName(au, null), ConvertClassToArray.GetValues(au, 0));
            }
            catch
            {
                return null;
            }
        }
        public DataTable AuthencationValues(Authencation au)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(_SPAuthencation, ConvertClassToArray.GetParamName(au, null), ConvertClassToArray.GetValues(au, 1));
            }
            catch
            {
                return null;
            }
        }
    }
}
